package com.wc.算法提高课.A第一章_动态规划.状态压缩DP.玉米田;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/5/11 11:44
 * @description https://www.acwing.com/problem/content/329/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 14, M = 1 << N, P = (int) 1e8;
    static int[] state = new int[M];
    static ArrayList<Integer>[] head = new ArrayList[M];
    static int[][] g = new int[N][N];
    // f[i][j] 表示前i行放完玉米状态为j的方案数
    static int[][] f = new int[N][M];
    static int m, n;

    public static void main(String[] args) {
        m = sc.nextInt();
        n = sc.nextInt();
        for (int i = 1; i <= m; i++) {
            for (int j = 0; j < n; j++) {
                g[i][j] = sc.nextInt();
            }
        }
        // 求出合法状态
        for (int i = 0; i < 1 << n; i++) {
            if (check(i)) state[++state[0]] = i;
        }
        for (int i = 0; i <= 1 << n; i++) {
            head[i] = new ArrayList<>();
        }
        // 求出转移边
        for (int i = 1; i <= state[0]; i++) {
            for (int j = 1; j <= state[0]; j++) {
                int a = state[i], b = state[j];
                if ((a & b) == 0) head[i].add(j);
            }
        }
        f[0][0] = 1;
        for (int i = 1; i <= m + 1; i++) {
            for (int j = 1; j <= state[0]; j++) {
                int a = state[j];
                // 检查a是否与g冲突
                boolean isBattle = false;
                for (int k = 0; k < n; k++) {
                    if (g[i][j] == 0 && (a >> k & 1) == 1) {
                        isBattle = true;
                        break;
                    }
                }
                if (!isBattle) {
                    for (int k : head[a]) {
                        int b = state[k];
                        f[i][a] = (f[i][a] + f[i - 1][b]) % P;
                    }
                }
            }
        }
        out.println(f[m + 1][0]);
        out.flush();
    }

    static boolean check(int x) {
        for (int i = 0; i < n; i++) {
            if ((x >> i & 1) == 1 && (x >> i + 1 & 1) == 1) {
                return false;
            }
        }
        return true;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
